package com.helloandroid.services

import androidx.core.content.edit
import com.helloandroid.MyApplication

class LocalResidentInfo(
        var bFlag:Boolean = true, // 用户打开了常驻通知
) {

    companion object{
        const val PrefResident = "s_pref_resident"
        const val KeyFlag = "key_flag"
    }
    fun init(){
        bFlag = MyApplication.getPerference(PrefResident).getBoolean(KeyFlag,true)
    }

    fun clearData(){
        MyApplication.getPerference(PrefResident).edit(commit = true){
            clear()
        }
    }

    fun updateFlag(newFlag:Boolean){
        if (newFlag != bFlag){
            bFlag = newFlag
            MyApplication.getPerference(PrefResident).edit(commit = true){
                putBoolean(KeyFlag,newFlag)
            }
        }
    }
}